package com.softer.wxzj.controller;

import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.DongleInfo;
import com.softer.wxzj.service.DongleInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: wxzj
 * @author: wxr
 * @create: 2019-05-20 14:26
 **/
@RestController
@RequestMapping("/dongleInfo")
@Slf4j
public class DongleInfoController {
    @Autowired
   private  DongleInfoService dongleInfoService;
    /**
     * 绑定加密狗
     * @param operId
     * @param keyCode
     * @return
     */
    @RequestMapping("/add")
    @LogRecord(description = "绑定加密狗",operationUnit = LogOperationUnit.DONGLE_INFO,operationType = LogOperationType.INSERT)
    public CommonResult insertDongleInfo(String operId,String keyCode) {
        return dongleInfoService.insertDongleInfo(operId,keyCode);
    }

    /**
     * 加密狗开启关闭
     * @param dongleInfo
     * @return
     */
    @RequestMapping("/update")
    @LogRecord(description = "加密狗开启关闭",operationUnit = LogOperationUnit.DONGLE_INFO,operationType = LogOperationType.UPDATE)
    public CommonResult update(DongleInfo dongleInfo) {
        return dongleInfoService.update(dongleInfo);
    }

    /**
     * 加密狗删除
     * @param id
     * @return
     */
    @RequestMapping("/delete")
    @LogRecord(description = "加密狗删除",operationUnit = LogOperationUnit.DONGLE_INFO,operationType = LogOperationType.DELETE)
    public CommonResult delete(String id) {
        return dongleInfoService.delete(id);
    }

    /**
     * 加密狗查看
     * @param page
     * @param dongleInfo
     * @return
     */
    @RequestMapping("/getList")
    @LogRecord(description = "字典类型查看",operationUnit = LogOperationUnit.DONGLE_INFO,operationType = LogOperationType.SELECT)
    public PageInfo<DongleInfo> getList(Page page, DongleInfo dongleInfo) {
        return dongleInfoService.getList(page,dongleInfo);
    }

}
